﻿<UserControl x:Class="Northwind.UI.WPF.OrderDetails"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Border Padding="5"
                Margin="4" CornerRadius="5"
                Background="{StaticResource mainBlueBrush}">
            <TextBlock Text="{Binding Order.Model.OrderID, 
                StringFormat={}{0} Order Details}"
                       Foreground="White"
                       FontWeight="Bold"
                       FontSize="12" />
        </Border>
        <Grid Margin="4" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <GroupBox Header="Summary">
                <Grid Margin="4" Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="6" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Text="Customer:" />
                    <TextBlock Grid.Column="2"> 
                        <Hyperlink 
                            Command="{Binding 
                                ShowCustomerDetailsCommand}"> 
                            <TextBlock 
                                Text="{Binding 
                                    Order.Customer.CompanyName}"/> 
                        </Hyperlink> 
                    </TextBlock>
                    <TextBlock Text="Order Date:" Grid.Row="1" />
                    <TextBlock Text="{Binding Order.Model.OrderDate,
                             StringFormat=d}"
                             Grid.Row="1"
                             Grid.Column="2" />
                    <TextBlock Text="Shipped Date:" Grid.Row="2"/>
                    <TextBlock Text="{Binding Order.Model.ShippedDate,
                             StringFormat=d}" Grid.Row="2" 
                             Grid.Column="2" />
                    <TextBlock Text="Freight:" Grid.Row="3"/>
                    <TextBlock Text="{Binding Order.Model.Freight,
                             StringFormat=c}" Grid.Row="3" 
                             Grid.Column="2" />
                    <TextBlock Text="Order Total:" Grid.Row="4"/>
                    <TextBlock Text="{Binding Order.Total,
                             StringFormat=c}" Grid.Row="4" 
                             Grid.Column="2" />
                </Grid>
            </GroupBox>
            <GroupBox Header="Details" Grid.Row="1">
                <ListView ItemsSource="{Binding 
                    Order.Model.OrderDetails}">
                    <ListView.Resources>
                        <Style TargetType="ListViewItem">
                            <Setter 
                                Property="HorizontalContentAlignment"
                                Value="Stretch" />
                        </Style>
                    </ListView.Resources>
                    <ListView.View>
                        <GridView>
                            <GridView.Columns>
                                <GridViewColumn Header="Product">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock 
                                                TextAlignment="Left"
                                                Text="{Binding 
                                                    Product.ProductName}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Quantity">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock TextAlignment="Center"
                                                   Text="{Binding Quantity}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="UnitPrice">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock 
                                                TextAlignment="Center" 
                                                Text="{Binding UnitPrice, 
                                                    StringFormat='{}{0:C}'}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView.Columns>
                        </GridView>
                    </ListView.View>
                </ListView>
            </GroupBox>
        </Grid>
    </Grid>
</UserControl>
